// 引入mutations 常量名
import { SET_CATEGORY_LIST } from "../constant-type"

// 引入请求
import { req } from "@/api"

// 三级分类列表数据
const state = {
    category: []
}
const mutations = {
    // 设置三级分类列表
    [SET_CATEGORY_LIST](state, payload) {
        state.category = payload.category
    }
}
const actions = {
    // 请求三级分类列表数据
    async getCategory({ commit }) {
        try {
            let res = await req.getCategoryList();
            // console.log(res);
            commit(SET_CATEGORY_LIST, { category: res })
        } catch (err) {
            alert(err.message)
        }
    }
}
const getters = {}


export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}